<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #operationBeforeExtend="{ record }">
        <a-link @click="openList(record)"><icon-list /> 分区列表</a-link>
      </template>
    </ma-crud>
    <!-- 列表组件 -->
    <list-data ref="listData" />
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import priceArea from '@/api/finance/priceArea'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import ListData from './datelist.vue'

import * as common from '@/utils/common'



const crudRef = ref()
const listData = ref()

const openList = (record) => {
  listData.value.open(record)
}
const options = reactive({
  id: 'price_area',
  pageLayout: 'fixed',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: "80%"
  },
  api: priceArea.getList,
  add: {
    show: true,
    api: priceArea.save,
    auth: ['finance:priceArea:save']
  },
  edit: {
    show: true,
    api: priceArea.update,
    auth: ['finance:priceArea:update']
  },
  delete: {
    show: true,
    api: priceArea.deletes,
    auth: ['finance:priceArea:delete']
  }
})

const columns = reactive([
  {
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入主键"
    }
  },
  {
    title: "名称",
    dataIndex: "name",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入名称"
    }
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'finance:priceArea' } </script>